<template>
  <div class="sidebar-fade" v-if="showSidebar">
    <div class="sidebar">
      <div class="sidebar-header">
        <div class="logo"></div>
        <!-- <img class="logo" src="../assets/image/home/logo.png" alt="" /> -->
        <img
          @click.stop="closeSidebar"
          class="close-btn"
          src="../assets/image/home/close.png"
          alt=""
        />
      </div>

      <div
        class=" sidebar-contentbox flex-row  justify-between items-center  "
        v-for="(item, index) in menuItems"
        :key="index"
        @click="navigateTo(item.route)"
      >
        <div class="sidebar-content flex-row items-center ">
          <!-- <img :src="item.icon" alt="" /> -->
          <div>{{ item.label }}</div>
        </div>
        <van-icon name="arrow" class="arrow-right" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    showSidebar: {
      type: Boolean,
      required: false,
      default: false, // 添加默认值
    },
  },
  data() {
    return {
      menuItems: [
        {
          label: this.$t("menu.home"),
          route: "/",
        },
        {
          label: this.$t("menu.synthesis"),
          route: "/synthesis",
        },
        {
          label: this.$t("menu.widedata"),
          route: "/widedata",
        },
        {
          label: this.$t("menu.team"),
          route: "/team",
        },
        {
          label: this.$t("menu.account"),
          route: "/account",
        },
        {
          label: this.$t("menu.nftList"),
          route: "/withdrawal",
        },
        {
          label: this.$t("menu.language"),
          route: "/language",
        },
        {
          label: this.$t("Exchange.Exchange2"),
          route: "/swap",
        },
      ],
    };
  },
  methods: {
    closeSidebar() {
      this.$emit("showSidebarcli"); // 使用 $emit 来更新父组件的状态
    },
    navigateTo(route) {
      if (route == "/jhs") {
        window.open("https://federal.guru/BKRU-SGWhitePaper.pdf", "_blank");
      } else {
        this.$router.push({ path: route });
      }
    },
  },
};
</script>

<style lang="less" scoped>
.sidebar-fade {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.8);
}
.sidebar {
  width: 504px;
  height: 100vh;
  background: rgba(26, 22, 27, 0.9);
  // background: url(../assets/image/home/sidebg.png) no-repeat;
  // background-size: 100% 100%;
  padding: 84px 38px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  .logo {
    width: 262px;
    height: 64px;
    margin: 70px 0 140px;
  }

  .close-btn {
    width: 28px;
    height: 28px;
  }
}
.sidebar-contentbox {
  margin-bottom: 80px;
  color: #fff;
}
.sidebar-content {
  font-size: 44px;

  img {
    width: 42px;
    height: 42px;
    margin-right: 20px;
  }
}
</style>
